<?php

/*
	* OpenGSP (c) 2011
	* Author(s): Christopher Martino
	* Module: license.base.php
	* Updated: 29/03/2011
	* http://opengsp.com/
*/

class License_BASE
{
	public static $curl_handle;
	
	public static $saved_value;

	function __construct(/* NULL Parameters */)
	{
		self::$curl_handle = curl_init();
		
		self::validate_license( );
		
		self::continue_output( );
	}
	
	public static function validate_license(/* NULL Parameters */)
	{
		curl_setopt(self::$curl_handle, CURLOPT_URL, 'license.opengsp.com/validate.php');
		curl_setopt(self::$curl_handle, CURLOPT_RETURNTRANSFER, 1);
		
		$parameters = array('HOST_DOMAIN' => urlencode($_SERVER['SERVER_NAME']), 'HOST_REQUEST' => urlencode(time(/* NULL */)));
		
		foreach($parameters as $key => $value) 
		{ 
			$requst_params .= $key.'='.$value.'&'; 
		}
		
		rtrim($requst_params,'&');

		curl_setopt(self::$curl_handle, CURLOPT_POST, count($$parameters));
		curl_setopt(self::$curl_handle, CURLOPT_POSTFIELDS, $parameters);

		self::$saved_value = curl_exec(self::$curl_handle);
		
		curl_close(self::$curl_handle);
	}
	
	public static function continue_output(/* NULL Parameters */)
	{
		if(self::$saved_value != "ACCEPTED_DATA_CONNECTION") die("OpenGSP: Unauthorized user attempt. Please register your domain at http://opengsp.com");
	}
}